package com.ascentive.finallyfast;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;

public class WelcomePage extends BaseActivity{

	CheckBox checkbox = null;
	SharedPreferences settings = null;
	/** Called when the activity is first created. */
	// @Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.welcome_screen);
		
		checkbox = (CheckBox) this.findViewById(R.id.dontshowagain_checkbox);
		checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
		    @Override
		    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		    	
		    	if(isChecked) savePref();
		    	buttonView.setChecked(isChecked);
		    }
		});
		
		Button button = (Button) this.findViewById(R.id.deepclean_button);
		button.setOnClickListener(new OnClickListener() {
			// @Override
			public void onClick(View v) {
				/**
				 * Called after splash times up. Do some action after splash
				 * times up. Here we moved to another main activity class
				 */
				getFinallyFastApplication().setFirstSelectedTab(1); // DEEP_CLEAN_PAGE
				startActivity(new Intent(WelcomePage.this,
						MainScreenActivity.class));
				finish();
			}
		});
		Button quickboostButton = (Button) this
				.findViewById(R.id.quickboost_button);
		quickboostButton.setOnClickListener(new OnClickListener() {
			// @Override
			public void onClick(View v) {

				/**
				 * Called after splash times up. Do some action after splash
				 * times up. Here we moved to another main activity class
				 */
				getFinallyFastApplication().setFirstSelectedTab(0); // QUICK_BOOST_PAGE
				startActivity(new Intent(WelcomePage.this,
						MainScreenActivity.class));
				finish();
			}
		});
		
		
	}
	public void savePref()
	{
//		SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
//		SharedPreferences.Editor editor = mPrefs.edit();
//	     editor.putBoolean("welcomeScreenShownPref", true);
//	     editor.commit(); // Very important to save the preference
	        
		settings = getSharedPreferences("my_prefs_file", MODE_PRIVATE);
		SharedPreferences.Editor editor1 = settings.edit();
		editor1.putBoolean("welcome", checkbox.isChecked());
		editor1.commit();
	}
	
}